package com.molichuxing.services.infrastructure.service.impl;

import java.util.List;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.molichuxing.services.infrastructure.bean.DrivingLicenseRecognitionBean;
import com.molichuxing.services.infrastructure.dao.DrivingLicenseRecognitionMapper;
import com.molichuxing.services.infrastructure.dto.request.create.DrivingLicenseRecognitionCreateDto;
import com.molichuxing.services.infrastructure.dto.response.DrivingLicenseRecognitionDto;
import com.molichuxing.services.infrastructure.service.DrivingLicenseRecognitionService;

/**
 * 
 * @author liyg
 * 驾驶证验证服务实现类
 * 2019-08-15
 * 
 */
@Service("drivingLicenseRecognitionService")
public class DrivingLicenseRecognitionServiceImpl implements DrivingLicenseRecognitionService{

	@Autowired
	private DrivingLicenseRecognitionMapper drivingLicenseRecognitionMapper;
	
	@Override
	public DrivingLicenseRecognitionDto getVerifyResult(Integer userId) {
		
		DrivingLicenseRecognitionDto dto=null;
		
		List<DrivingLicenseRecognitionBean> list = drivingLicenseRecognitionMapper.getListByUserId(userId);
		if( null != list && list.size() > 0 ) {
			DrivingLicenseRecognitionBean bean = list.get(0);
			dto= new DrivingLicenseRecognitionDto();
			BeanUtils.copyProperties(bean, dto);
		}
		
		return dto;
	}

	/**
	 * 保存
	 * @param createDto
	 * @return
	 */
	@Override
	public Boolean create(DrivingLicenseRecognitionCreateDto createDto) {
		DrivingLicenseRecognitionBean bean=new DrivingLicenseRecognitionBean();
		BeanUtils.copyProperties(createDto, bean);
		int num = drivingLicenseRecognitionMapper.create(bean);
		return num==1;
	}
}
